home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / archiver / briksrc.zoo / brik.h < prev    next >
C/C++ Source or Header  |  1991-05-16  |  9KB  |  212 lines

  1. /* ::[[ @(#) brik.h 1.31 89/07/12 03:18:00 ]]:: */
  2.  
  3. /*
  4. Checksum: 3082630653      (check or update this with "brik")
  5. */
  6.  
  7. /*
  8. The contents of this file are hereby released to the public domain.
  9.  
  10.                                    -- Rahul Dhesi 1989/03/10
  11. */
  12.  
  13. /*
  14. Brik assumes eight-bit bytes and the ASCII character set.  There may also
  15. be some implicit assumptions that the parity bit in characters in text
  16. files is always zero.
  17.  
  18. Options for compiling brik.c on various systems.
  19.  
  20. GENTAB      If this symbol is defined, brik will generate a CRC table at
  21.             runtime rather than using one statically stored in the
  22.             executable code.  This will make brik start up a tad slower
  23.             but will make the code smaller, since the CRC table takes
  24.             up about 256 * sizeof(unsigned long) bytes.  The code is
  25.             smaller only if your C compiler correctly handles
  26.             uninitialized static data by allocating space for it only
  27.             at runtime.  Not all compilers are this smart.  If yours
  28.             isn't, definining GENTAB can actually increase the size
  29.             of your code.
  30. NOTRAIL_B   Define this if a trailing "b" is not permitted in the fopen
  31.             mode string to open files in binary mode.  To the best of
  32.             my knowledge, only Ultrix objects to a trailing "b".
  33. BIN_STDIN_OK  If stdin can be a binary file, this should be defined so
  34.             that brik will allow binary CRCs to be calculated for stdin.
  35.             If it is not defined, brik will give an error message if a
  36.             binary CRC calculation is attempted on stdin.  Should be
  37.             defined for **IX and similar environments.
  38. WILDCARD    Define this if wildcards are to be expanded by this program.
  39.             If WILDCARD is defined, then a function nextfile() must also
  40.             be available that conforms to the specifications in turboc.c.
  41. USEINDEX    Define this symbol to make brik use index() instead of strchr().
  42.             Probably needed only 4.2BSD and earlier.
  43. BRKTST      If defined, brik will explicitly test for user interrupts in
  44.             all long loops, so that the program can easily be interrupted
  45.             on microcomputers that don't accept user interrupts
  46.             asynchronously.  If BRKTST is defined, brik will call the
  47.             function brktst() periodically.  This function should check
  48.             for a user interrupt and abort the program if it has occurred.
  49. NIXSEEK     If seeks are UNIX-like, i.e., seeks are possible at any byte
  50.             offset even in text files, then NIXSEEK may be defined to make
  51.             the -gW option perform faster.  If NIXSEEK is not defined, all
  52.             seeks will be to line boundaries using an offset already
  53.             obtained from ftell().  Even on non-UNIX-like systems, it *may*
  54.             be possible to define NIXSEEK, since when brik seeks to an
  55.             arbitrary byte boundary, it always immediately reads
  56.             sequentially forward to a line boundary.  Seeks are needed only
  57.             for the -gW option, which causes brik to seek back to where
  58.             it found the Checksum: header so it can update the stored CRC.
  59. CHECKSEEK   If seeks are flaky it may help to define CHECKSEEK.  In this
  60.             case brik will seek, read a line, seek again, read the line
  61.             again, compare the two, and proceed only if both reads gave the
  62.             checksum header it was looking for, thus confirming that the
  63.             seeks are working right.  This is a very conservative strategy
  64.             to minimize the risk of corrupting a file by overwriting it at
  65.             the wrong place due to a faulty seek.
  66. BUG1,       If ftell() just after fgets() does not return the correct seek
  67. BUG2        offset of the next line, one of these two symbols can be defined
  68.             (but not both).  Each adds different bug fix code and one of them
  69.             may work for you.
  70. ANSIPROTO   If defined, ANSI-style function prototypes will be used.
  71. STDINCLUDE  If defined, ANSI-standard include files will be included.
  72.             If not defined, many standard functions will be declared
  73.             explicitly.
  74. NDEBUG      If this symbol is defined, assert() macros throughout the
  75.             brik code will get nulled out, making the executable code
  76.             slightly smaller.
  77. DEBUG       If this symbol is defined, an undocumented -d switch will
  78.             be accepted that will cause information about Checksum:
  79.             header reads and writes to be printed.
  80. EXITBUG     Define this symbol if the exit() function has a bug causing
  81.             anomalous results if the exit code is not exactly 1.
  82. AVOID_MACROS  Brik uses macros for speed in case-insensitive string
  83.             comparisons.  If you get "macro too long" or "expression too
  84.             complex" or similar compilation errors, you can define the
  85.             symbol AVOID_MACROS.  This will cause slower but more compact
  86.             code to be used that does not use long macros, possibly
  87.             allowing compilation.
  88. LOWERIT     If a fast macro or function call is available that will accept
  89.             a single parameter of type "int" and return its lowercase
  90.             value, the symbol LOWERIT may be defined to invoke it.  This
  91.             macro or function must accept any int value, whether or not
  92.             it represents an uppercase character.  Since LOWERIT is
  93.             never called with side-effects, it can safely be a macro.
  94.             If any include file is needed, include it here.  For example,
  95.             if a tolower() macro or function is available that requires
  96.             <ctype.h> to be included, use "#include <ctype.h>" followed
  97.             by "#define LOWERIT tolower" somewhere in brik.h.
  98. STRNICMP    If a case-insensitive implementation of strncmp is available,
  99.             define STRNICMP to be equivalent to it.  If STRNICMP is not
  100.             defined, brik uses its own case-insensitive string comparison
  101.             function.  STRNICMP must accept the same arguments as strncmp.
  102. BINCHAR     Brik uses a table look-up to test if a character is binary, to
  103.             warn the user if a text mode CRC is being used on a binary file.
  104.             The user may optionally define his own BINCHAR(c) macro, which
  105.             must return nonzero if c should be considered a binary character.
  106. NOCASE      This symbol should be defined if the filesystem is case-
  107.             insensitive.  It will cause all filenames printed to be in
  108.             lowercase.  This will help make a list of files generated by
  109.             the -G option to be more easily usable on systems with case-
  110.             sensitive filesystems, as most file transfer mechanisms (e.g.
  111.             zmodem, kermit, zoo archives) will be compatible with this.
  112. CTRLZ_CHECK If this symbol is defined, special-case code is compiled in
  113.             that will more reliably detect when a file is binary, even
  114.             if control Z occurs early in a file causing the C runtime
  115.             library to falsely assume end-of-file.
  116.  
  117.                                      -- Rahul Dhesi
  118.                                         1989/07/07
  119.                                         UUCP:      iuvax!bsu-cs!dhesi
  120.                                         Internet:  dhesi@bsu-cs.bsu.edu
  121. */
  122.  
  123. #ifdef TURBOC
  124. # define GENTAB
  125. # define WILDCARD
  126. # define ANSIPROTO
  127. # define STDINCLUDE
  128. # define BRKTST
  129. # define NOCASE
  130. # define STRNICMP    strnicmp
  131. # include <ctype.h>
  132. # define LOWERIT tolower
  133. # define CTRLZ_CHECK
  134. #endif /* TURBOC */
  135.  
  136. /* Microsoft C 5.1 -- use supplied "makefile.msc" makefile -- not tested */
  137. #ifdef MSC51
  138. # define WILDCARD
  139. # define ANSIPROTO
  140. # define BRKTST
  141. /* # define BUG1 or BUG2 if necessary -- not tested */
  142. # define NOCASE
  143. # define STRNICMP    strnicmp
  144.   int strnicmp (char *, char *, unsigned);
  145. # include <ctype.h>
  146. # define LOWERIT tolower
  147. #endif /* MSC51 */
  148.  
  149. #ifdef SYS_V
  150. # define NIXSEEK
  151. # define BIN_STDIN_OK
  152. #endif /* SYS_V */
  153.  
  154. #ifdef BSD
  155. # define NIXSEEK
  156. # define USEINDEX
  157. # define BIN_STDIN_OK
  158. #endif /* BSD */
  159.  
  160. #ifdef VMS
  161. # define WILDCARD
  162. # define CHECKSEEK
  163. # define BUG2
  164. # define EXITBUG
  165. # define NOCASE
  166. #endif /* VMS */
  167.  
  168. #ifdef ATARI
  169. # define ANSIPROTO
  170. # d